<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<LINK 
href="showAllOrg.files/style.htm" rel=stylesheet><LINK 
href="showAllOrg.files/content.htm" rel=stylesheet>

		<script type="text/javascript">
		    var djConfig = {
				isDebug:true,
				parseOnLoad:true,
				usePlainJson:true
		    };
		</script>
		 
		<script type="text/javascript" src="dojo/dojo/dojo.js"></script>
		<script type="text/javascript" src="dojo/dijit/dijit.js"></script>

		<script type="text/javascript">
    		dojo.require("dijit.form.Button");
    		dojo.require("dojo.rpc.JsonService");    	
    	</script>
    	<script language="JavaScript">

    	 	//获得服务
			var queryAnswerPriceService = new dojo.rpc.JsonService("price/QueryAnswerPriceService?smd");

			//得到所有询价单
			var queryPriceFormList = null;			
			//console.dir(queryPriceFormList);

			//报价单
			var answerPriceFormGlobal;

			
			//根据选项显示询价单
			function show_query_price_form() {
				queryAnswerPriceService.getQueryPriceForm().addCallback(show_query_price_form_callback);
			}
			function show_query_price_form_callback(result) {
				var option = document.getElementById("option").value;
				
				queryPriceFormList = result;
				console.dir(queryPriceFormList);
				
				if (option == "null") {
					clear_query_price_form();
				} else if (option == "all") {
					show_all_query_price_form();
				} else if (option == "done") {
					show_done_query_price_form();
				} else {
					show_undone_query_price_form();
				}
			}
			//清空询价单表
			function clear_query_price_form() {
				var rows = document.getElementById("query_price_form").tBodies[0].rows;
				for (var i = rows.length - 1; i > 0; i--) {
					var rIndex = rows[i].sectionRowIndex;
					rows[i].parentNode.deleteRow(rIndex);
				}
			}
			//显示所有询价单
			function show_all_query_price_form() {
				var results = queryPriceFormList.list;
				clear_query_price_form();
				//console.dir(results);
				for (var i in results) {
					add_query_price_form_row(results[i].ID, results[i].timeString, results[i].start,
							results[i].end, results[i].loc, results[i].landTransport, results[i].declare,
							results[i].order, results[i].proceed);
				}
			}
			//显示已处理询价单
			function show_done_query_price_form() {
				var results = queryPriceFormList.list;
				clear_query_price_form();
				for (var i in results) {
					if (results[i].proceed == true) {
						add_query_price_form_row(results[i].ID, results[i].timeString, results[i].start,
								results[i].end, results[i].loc, results[i].landTransport, results[i].declare,
								results[i].order, results[i].proceed);
					}
				}
			}
			//显示未处理询价单
			function show_undone_query_price_form() {
				var results = queryPriceFormList.list;
				clear_query_price_form();
				for (var i in results) {
					if (results[i].proceed == false) {
						add_query_price_form_row(results[i].ID, results[i].timeString, results[i].start,
								results[i].end, results[i].loc, results[i].landTransport, results[i].declare,
								results[i].order, results[i].proceed);
					}
				}
			}
			//向表格添加行
			function add_query_price_form_row(id, time, start, end, loc,
					landTransport, declare, order, proceed) {
				var tbl, tr, td, anchor;

				tbl = document.getElementById("query_price_form");
				tr = document.createElement("tr");
				tr.className = "gridtreven";
				
				/*
				td = document.createElement("td");
				td.appendChild(document.createTextNode(id));
				tr.appendChild(td);
				*/
				add_content_to_tr(id, tr);
				add_content_to_tr(time, tr);
				add_content_to_tr(start, tr);
				add_content_to_tr(end, tr);
				add_content_to_tr(loc, tr);
				if (landTransport == true) {
					add_content_to_tr("是", tr);
				} else {
					add_content_to_tr("否", tr);
				}
				if (declare == true) {
					add_content_to_tr("是", tr);
				} else {
					add_content_to_tr("否", tr);			
				}
				if (order == true) {
					add_content_to_tr("是", tr);
				} else {
					add_content_to_tr("否", tr);
				}
				if (proceed == true) {					//若已处理，点击，则显示报价单
					td = document.createElement("td");
					anchor = document.createElement("a");
					//设置属性
					anchor.href = "#";
					//直接赋值anchor.onclick = 'alert("bla...ba...")';不好使
					anchor.setAttribute("onclick", 'show_answer_price_form('+ id + ')');
					//将数据加入anchor中
					anchor.appendChild(document.createTextNode("查看报价单"));
					//讲anchor加入td中
					td.appendChild(anchor);
					tr.appendChild(td);
					//add_content_to_tr();
				} else {								//若未处理，则报价
					td = document.createElement("td");
					anchor = document.createElement("a");
					//设置属性
					anchor.href = "#";
					//直接赋值anchor.onclick = 'alert("bla...ba...")';不好使
					anchor.setAttribute("onclick", 'answer_price(' + id + ')');
					//将数据加入anchor中
					anchor.appendChild(document.createTextNode("报价"));
					//讲anchor加入td中
					td.appendChild(anchor);
					tr.appendChild(td);
				}			

				//显示详情
				td = document.createElement("td");
				anchor = document.createElement("a");
				//设置属性
				anchor.href = "#";
				//直接赋值anchor.onclick = 'alert("bla...ba...")';不好使
				anchor.setAttribute("onclick", 'show_query_price_form_detail(' + id + ')');
				//将数据加入anchor中
				anchor.appendChild(document.createTextNode("详情"));
				//讲anchor加入td中
				td.appendChild(anchor);
				tr.appendChild(td);
				
				tbl.tBodies[0].appendChild(tr);
			}
			//向表格的单元里添加数据
			function add_content_to_tr(content, tr) {
				td = document.createElement("td");
				td.appendChild(document.createTextNode(content));
				tr.appendChild(td);
			}
			//对ID为id的询价单报价
			function answer_price(id) {
				var answerPriceForm;
				
				for (var i in queryPriceFormList.list) {
					if (queryPriceFormList.list[i].ID == id) {
						answerPriceForm = queryAnswerPriceService.answerPrice(queryPriceFormList.list[i]);
						break;
					}
				}
				answerPriceForm.addCallback(answer_price_callback);
			}
			//报价callback函数
			function answer_price_callback(result) {				
				console.dir(result);

				answerPriceFormGlobal = result;
				
				var shipName = "", scdID = "";
				if (result.queryPriceForm.shipSchedule != null) {
					shipName = result.queryPriceForm.shipSchedule.shipInfo.name;
					scdID = result.queryPriceForm.shipSchedule.id;
				}
				
				//result.id = 2;
				//输出报价单详情html
				var text = "";
				var totalCost = result.shippingCost;
				text = text + "<h4>" + result.id + "号报价单明细</h4><hr/>";
				text = text + "<p>致" + result.queryPriceForm.customer.id;
				text = text + "<table class='gridarea' cellSpacing='1' cellPadding='2' align='center' width='360'>";
				text = text + "    <tr class='gridtreven'>";
				text = text + "        <td class='gridtitletd' vAlign='middle' width='50'>船名</td>";
				text = text + "        <td width='50'>" + shipName + "</td>";
				text = text + "        <td class='gridtitletd' vAlign='middle' width='50'>航次</td>";
				text = text + "        <td width='210'>" + scdID + "</td>";
				text = text + "    </tr>";
				text = text + "    <tr class='gridtreven'>";
				text = text + "        <td class='gridtitletd' vAlign='middle' colspan='2' width='100'>发船日期</td>";
				if (result.queryPriceForm.shipSchedule != null) {
					text = text + "        <td colspan='2' width='160'>" + result.queryPriceForm.shipSchedule.leaveTime + "</td>";
				} else {
					text = text + "		   <td colspan='2' width='160'></td>";
				}
				text = text + "    </tr>";
				text = text + "    <tr class='gridtreven'><td class='gridtitletd' vAlign='middle' colspan='2' width='100'>委托业务</td><td class='gridtitletd' vAlign='middle' colspan='2' width='160'>价格信息</td></tr>";
				text = text + "    <tr class='gridtreven'><td colspan='2' width='100'>海运</td><td colspan='2' width='160'>" + result.shippingCost + "</td></tr>";
				if (result.landCost != null) {
					text = text + "    <tr class='gridtreven'><td colspan='2' width='100'>陆运</td><td colspan='2' width='160'>" + formatFloat(result.landCost, 2) + "</td></tr>";
					totalCost += result.landCost;
				}
				if (result.declareCost != null) {
					text = text + "    <tr class='gridtreven'><td colspan='2' width='100'>报关</td><td colspan='2' width='160'>" + formatFloat(result.declareCost, 2) + "</td></tr>";
					totalCost += result.declareCost;
				}
				if (result.orderCost != null) {
					text = text + "    <tr class='gridtreven'><td colspan='2' width='100'>订舱</td><td colspan='2' width='160'>" + formatFloat(result.orderCost, 2) + "</td></tr>";	
					totalCost += result.orderCost;
				}
				text = text + "    <tr class='gridtreven'><td class='gridtitletd' vAlign='middle' colspan='2' width='100'>费用总额</td><td colspan='2' width='160'>" + formatFloat(totalCost, 2) + "</td></tr>";
				text = text + "</table>";
				text = text + "<a href='#' onClick=\"answer_price_assure()\">确定</a> <a href='#' onClick='answer_price_cancel()'>取消</a>";
				text = text + "</p>";
					
				document.getElementById("answer_price_form_detail").innerHTML = text;				
			}
			//确定报价
			function answer_price_assure() {
				//console.dir(result);
				queryAnswerPriceService.putAnswerPriceForm(answerPriceFormGlobal).addCallback(answer_price_assure_callback);
			}
			function answer_price_assure_callback() {
				alert("报价成功！");
				document.getElementById("answer_price_form_detail").innerHTML = "";
				show_query_price_form();
			}
			//取消报价
			function answer_price_cancel() {
				document.getElementById("answer_price_form_detail").innerHTML = "";
			}

			//查看报价单:id
			function show_answer_price_form(id) {
				queryAnswerPriceService.getAnswerPriceForm().addCallback(function (result) {
					console.dir(result);

					for (var i in result.list) {
						if (result.list[i].id == id) {
							var shipName = "", scdID = "";
							if (result.list[i].queryPriceForm.shipSchedule != null) {
								shipName = result.list[i].queryPriceForm.shipSchedule.shipInfo.name;
								scdID = result.list[i].queryPriceForm.shipSchedule.id;
							}
							
							//result.id = 2;
							//输出报价单详情html
							var text = "";
							var totalCost = result.list[i].shippingCost;
							text = text + "<h4>" + result.list[i].id + "号报价单明细</h4><hr/>";
							text = text + "<p>致" + result.list[i].queryPriceForm.customer.id;
							text = text + "<table class='gridarea' cellSpacing='1' cellPadding='2' align='center'>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle' width='50'>船名</td>";
							text = text + "        <td width='50'>" + shipName + "</td>";
							text = text + "        <td class='gridtitletd' vAlign='middle' width='50'>航次</td>";
							text = text + "        <td width='210'>" + scdID + "</td>";
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle' colspan='2' width='100'>发船日期</td>";
							if (result.list[i].queryPriceForm.shipSchedule != null) {
								text = text + "        <td colspan='2' width='160'>" + result.list[i].queryPriceForm.shipSchedule.leaveTime + "</td>";
							} else {
								text = text + "		   <td colspan='2' width='160'></td>";
							}
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'><td class='gridtitletd' vAlign='middle' colspan='2' width='100'>委托业务</td><td class='gridtitletd' vAlign='middle' colspan='2' width='160'>价格信息</td></tr>";
							text = text + "    <tr class='gridtreven'><td colspan='2' width='100'>海运</td><td colspan='2' width='160'>" + formatFloat(result.list[i].shippingCost, 2) + "</td></tr>";
							if (result.list[i].landCost != null) {
								text = text + "    <tr class='gridtreven'><td colspan='2' width='100'>陆运</td><td colspan='2' width='160'>" + formatFloat(result.list[i].landCost, 2) + "</td></tr>";
								totalCost += result.list[i].landCost;
							}
							if (result.list[i].declareCost != null) {
								text = text + "    <tr class='gridtreven'><td colspan='2' width='100'>报关</td><td colspan='2' width='160'>" + formatFloat(result.list[i].declareCost, 2) + "</td></tr>";
								totalCost += result.list[i].declareCost;
							}
							if (result.list[i].orderCost != null) {
								text = text + "    <tr class='gridtreven'><td colspan='2' width='100'>订舱</td><td colspan='2' width='160'>" + formatFloat(result.list[i].orderCost, 2) + "</td></tr>";	
								totalCost += result.list[i].orderCost;
							}
							text = text + "    <tr class='gridtreven'><td class='gridtitletd' vAlign='middle' colspan='2' width='100'>费用总额</td><td colspan='2' width='160'>" + formatFloat(totalCost, 2) + "</td></tr>";
							text = text + "</table>";
							text = text + "<a href='#' onClick='answer_price_cancel()'>关闭</a>";
							text = text + "</p>";
								
							document.getElementById("answer_price_form_detail").innerHTML = text;
							break;
						}
					}
				});
			}

			//查看询价单详情:id
			function show_query_price_form_detail(id) {
				queryAnswerPriceService.getQueryPriceForm().addCallback(function (result) {
					console.dir(result);
					
					for (var i in result.list) {
						if (result.list[i].ID == id) {
							var queryPriceForm = result.list[i];
							console.dir(queryPriceForm);
							
							var text = "";

							text = text + "<h4>" + id + "号询价单明细</h4><hr/>";
							text = text + "<table class='gridarea' cellSpacing='1' cellPadding='2' align='center'>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>发货人</td>";
							text = text + "        <td>" + queryPriceForm.customer.name + "</td>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>地址</td>";
							text = text + "        <td colspan='5'>" + queryPriceForm.customer.addr + "</td>";
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>联系人</td>";
							text = text + "        <td>" + queryPriceForm.customer.customerContact.name + "</td>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>电话</td>";
							text = text + "        <td colspan='5'>" + queryPriceForm.customer.customerContact.OTel + "</td>";
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>传真</td>";
							if (queryPriceForm.customer.fax == null) {
								text = text + "        <td></td>";
							} else {
								text = text + "        <td>" + queryPriceForm.customer.fax + "</td>";
							}
							text = text + "        <td class='gridtitletd' vAlign='middle'>E_mail</td>";
							text = text + "        <td colspan='5'>" + queryPriceForm.customer.customerContact.email + "</td>";
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'><td class='gridtitletd' vAlign='middle'>货物名称</td><td colspan='7'>" + queryPriceForm.goods.name + "</td></tr>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle' rowspan='2'>货物种类</td>";
							text = text + "        <td rowspan='2'>" + queryPriceForm.goods.type + "</td>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>冷冻温度</td>";
							if (queryPriceForm.goods.temp == null) {
								text = text + "        <td colspan='5'></td>";
							} else {
								text = text + "        <td colspan='5'>" + queryPriceForm.goods.temp + "</td>";
							}
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>危险等级</td>";
							if (queryPriceForm.goods.dangerClass == null) {
								text = text + "        <td></td>";
							} else {
								text = text + "        <td>" + queryPriceForm.goods.dangerClass + "</td>";
							}
							text = text + "        <td class='gridtitletd' vAlign='middle'>危规页码</td>";
							if (queryPriceForm.goods.dangerProperty == null) {
								text = text + "        <td></td>";
							} else {
								text = text + "        <td>" + queryPriceForm.goods.dangerProperty + "</td>";
							}
							text = text + "        <td class='gridtitletd' vAlign='middle'>联合国编号</td>";
							if (queryPriceForm.goods.UNID == null) {
								text = text + "        <td></td>";
							} else {
								text = text + "        <td>" + queryPriceForm.goods.UNID + "</td>";
							}
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>件数</td><td></td>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>重量</td><td>" + queryPriceForm.goods.weight + "</td>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>体积</td><td colspan='3'>" + queryPriceForm.goods.size + "</td>";
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle' rowspan='2'>货物数量</td>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>箱型、箱量</td>";
							text = text + "        <td colspan='6'>" + queryPriceForm.goods.goodsNum.GP20 + "&times;20GP" + queryPriceForm.goods.goodsNum.GP40 + "&times;40GP" + queryPriceForm.goods.goodsNum.HQ40 + "&times;40HQ" + "</td>";
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>散货</td>";
							text = text + "        <td colspan='6'>" + queryPriceForm.goods.goodsNum.CBM + "&times;CBM" +"</td>";
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle' rowspan='3'>路线要求</td>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>船名</td>";
							if (queryPriceForm.shipSchedule == null) {
								text = text + "        <td colspan='6'></td>";
							} else {
								text = text + "        <td colspan='6'>" + queryPriceForm.shipSchedule.shipInfo.name + "</td>";
							}
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>航次</td>";
							if (queryPriceForm.shipSchedule == null) {
								text = text + "        <td colspan='6'></td>";
							} else {
								text = text + "        <td colspan='6'>" + queryPriceForm.shipSchedule.id + "</td>";
							}
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>启运港</td>";
							text = text + "        <td>" + queryPriceForm.start + "</td>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>目的港</td>";
							text = text + "        <td colspan='4'>" + queryPriceForm.end + "</td>";
							text = text + "    </tr>";
							text = text + "    <tr class='gridtreven'>";
							text = text + "        <td class='gridtitletd' vAlign='middle'>委托业务</td>";
							text = text + "        <td colspan='7'>";
							if (queryPriceForm.landTransport == true) {
								text = text + "&nbsp;陆运";
							}
							if (queryPriceForm.declare == true) {
								text = text + "&nbsp;报关";
							}
							if (queryPriceForm.order == true) {
								text = text + "&nbsp;订舱";
							}
							text = text + "        </td>";
							text = text + "    </tr>";
							text = text + "</table>";
							text = text + "<a href='#' onClick=\"document.getElementById('query_price_form_detail').innerHTML = ''\">关闭</a>";
							
							document.getElementById("query_price_form_detail").innerHTML = text;
							break;
						}
					}
				});
			}
			function formatFloat(src, pos)
			{
			    return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos);
			}
		</script>   	    	
		
		<title>询报价</title>
	</head>
	
	<body>
		
		
		<FONT style="FONT-SIZE: 18px" face=隶书 color=#3656b9 
;>询报价</FONT><BR><IMG src="showAllOrg.files/line2.gif"><BR>

<center>
			<form id="show_result_option">
				<label for="option">查看：</label>
				<select id="option" onchange="show_query_price_form();">
					<option selected value="null" >none</option>
					<option value="all">全部询价单</option>
					<option value="done">已处理询价单</option>
					<option value="undone">未处理询价单</option>
				</select>
			</form>
			
			<div>
			<fieldset>
					<table  class='gridarea' cellSpacing='1' cellPadding='2' align='center' id="query_price_form">
						<tr>
							<td class='gridtitletd' vAlign='middle'>编号</td>
							<td class='gridtitletd' vAlign='middle'>询价时间</td>
							<td class='gridtitletd' vAlign='middle'>起运港</td>
							<td class='gridtitletd' vAlign='middle'>目的港</td>
							<td class='gridtitletd' vAlign='middle'>货物所在地</td>
							<td class='gridtitletd' vAlign='middle'>陆运</td>
							<td class='gridtitletd' vAlign='middle'>报关</td>
							<td class='gridtitletd' vAlign='middle'>订舱</td>
							<td class='gridtitletd' vAlign='middle'>状态</td>
							<td class='gridtitletd' vAlign='middle'>操作</td>
						</tr>
					</table>
					</fieldset>
			</div>
			<!-- 报价单详情 -->
			<div id="answer_price_form_detail"></div>
			
			<!-- 询价单详情 -->
			<div id="query_price_form_detail"></div>
		</center>
	</body>
</html>
